Skip to content

Conversation

mathsvisualization
Copy link

Motivation

In the current interactive scene implementation, object grabbing is limited to the X and Y axes.
This makes it difficult to manipulate objects in full 3D space without writing extra transformation code.

This update adds Z-axis grabbing support, enabling depth movement directly through interactive mode.
It improves usability for 3D scene creation and makes interactive object positioning more intuitive.

Proposed changes

  • interactive_scene.py – Extended the grab-and-move logic to include Z-axis handling alongside X and Y.
  • default_config.yml – Updated configuration to include parameters for enabling and controlling Z-axis grabbing.

Test

Code:

from manimlib import *

class TestingZGrab(InteractiveScene):
    def construct(self):
        # Testing ZGrab
        z = Cube()
        self.add(z)
        
    def on_key_press(self, symbol, modifiers):
        super().on_key_press(symbol, modifiers)
        
        char = chr(symbol)
        if char in GRAB_KEYS:
            self.text = Text(f"Key Pressed: {chr(symbol)}")
            self.text.fix_in_frame()
            self.text.to_edge(UR)
            self.add(self.text)
    
    def on_key_release(self, symbol, modifiers):
        super().on_key_release(symbol, modifiers)
        
        char = chr(symbol)
        if char in GRAB_KEYS:
            self.remove(self.text)

2025-08-09.08-30-20.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant